getFunctions = {
    selectOne : function(){
        // Delete now the message
	$(".selectCheckBox").on("click",function(){
	    if(this.checked){
                // Select Single Checkbox
                var list = $(':checkbox[name="selectCheckBox[]"]:checked').map(function(){
                    return $(this).attr("data-id"); // Get an ID of the document
                    }).get().join(',');
                    console.log(list)
               
            }else{
                // Remove Unchecked ID in the textbox
                var list = $(':checkbox[name="selectCheckBox[]"]:checked').map(function(){
                    return $(this).attr("data-id"); // Get an ID of the document
                    }).get().join(',');
                    console.log(list)
                
            }
	});
    },
    selectAll : function(){
        // Delete now the message
	$(".selectAll").on("click",function(){
	    if(this.checked){
                $(".selectCheckBox").each(function(){
                    $(this).prop("checked", true)
                    // Select Single Checkbox
                    var list = $(':checkbox[name="selectCheckBox[]"]:checked').map(function(){
                    return $(this).attr("data-id"); // Get an ID of the document
                    }).get().join(',');
                    console.log(list)
                    
                });
            }else{
                $(".selectCheckBox").each(function(){
                    $(this).prop("checked", false)
                    // Remove Unchecked ID in the textbox
                    var list = $(':checkbox[name="selectCheckBox[]"]:checked').map(function(){
                    return $(this).attr("data-id"); // Get an ID of the document
                    }).get().join(',');
                    console.log(list)
                });
            }
	});
    }
}

settings = {
    setting_landing_page : function(){
	$("body").on("change",".setting_landing_page",function(){
	    var param_url = String(window.location);
	    if ($(this).is(':checked')) {
		//var conf = "Are you sure do you want to set this as the default landing page?";
		//jConfirm(conf, 'Confirmation Dialog', '', '', '', function(answer) {
		//    if (answer == true) {
			$.ajax({
			    type	:	"POST",
			    url	:	"/ajax/settings",
			    dataType:	"json",
			    data 	:	{action:"landing_page",param_url:param_url},
			    success	:	function(e){
			       if (e.noti=="Page was successfully set.") {
				   var newjAlert = new jAlert( e.noti, "","", "", "", function(){});
			       newjAlert.themeAlert('jAlert2');	
			       }
			    }
			});
		//    }else{
		//	 $(".setting_landing_page").prop('checked', false);
		//    }
		//});
	    }else{
		//var conf = "Do you want to remove this as your default landing page?";
		//jConfirm(conf, 'Confirmation Dialog', '', '', '', function(answer) {
		//    if (answer == true) {
			$.ajax({
			    type	:	"POST",
			    url	:	"/ajax/settings",
			    dataType:	"json",
			    data 	:	{action:"landing_page_remove",param_url:param_url},
			    success	:	function(e){
			       if (e.noti=="Page was successfully remove.") {
				   var newjAlert = new jAlert( e.noti, "","", "", "", function(){});
				   newjAlert.themeAlert('jAlert2');
			       }
			    }
			});
		//    }else{
		//	$(".setting_landing_page").prop('checked', true);
		//    }
		//});
	    }
	    
	    
	})
    }
}

$(document).ready(function(){
    $("body").click(function(){
	$(".updates_settings").popover('hide');	
    });
    
    getFunctions.selectOne();
    getFunctions.selectAll();
    $(".updates_settings").popover("show");
    // Settings
    settings.setting_landing_page();
});